<!-- f r o m 7 5  2 7 1  8 9 2 0 -->
<template>
  <a-row :gutter="24">
    <a-col :md="24">
      <a-card :style="cardStyle" :bordered="false">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
          <!-- 搜索区域 -->
          <a-form layout="inline" @keyup.enter.native="searchQuery">
            <a-row :gutter="24">
              <a-col :md="6" :sm="24">
                <a-form-item label="产品名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
                  <a-input placeholder="请输入产品名称查询" v-model="queryParam.supplier"></a-input>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="任务单号" :labelCol="labelCol" :wrapperCol="wrapperCol">
                  <a-input placeholder="请输入任务单号查询" v-model="queryParam.telephone"></a-input>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="所属行业" :labelCol="labelCol" :wrapperCol="wrapperCol">
                  <a-input placeholder="请输入所属行业查询" v-model="queryParam.phonenum"></a-input>
                </a-form-item>
              </a-col>
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-col :md="6" :sm="24">
                  <a-button type="primary" @click="searchQuery">查询</a-button>
                  <a-button style="margin-left: 8px" @click="searchReset">重置</a-button>
                </a-col>
              </span>
            </a-row>
          </a-form>
        </div>
        <!-- 操作按钮区域 -->
        <div class="table-operator"  style="margin-top: 5px">
          <a-button  @click="handleAdd" type="primary" icon="plus">新增</a-button>
          <a-upload v-if="btnEnableList.indexOf(1)>-1" name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
            <a-popover title="导入注意点">
              <template slot="content">
                <p><a target="_blank" href="/doc/customer_template.xls"><b>客户Excel模板下载</b></a></p>
              </template>
              <a-button type="primary" icon="import">导入</a-button>
            </a-popover>
          </a-upload>
          <a-button type="primary" icon="download" @click="handleExportXls('客户信息')">导出</a-button>
          <a-dropdown>
            <a-menu slot="overlay">
              <a-menu-item key="1" v-if="btnEnableList.indexOf(1)>-1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
              <a-menu-item key="2" v-if="btnEnableList.indexOf(1)>-1" @click="batchSetStatus(true)"><a-icon type="check-square"/>启用</a-menu-item>
              <a-menu-item key="3" v-if="btnEnableList.indexOf(1)>-1" @click="batchSetStatus(false)"><a-icon type="close-square"/>禁用</a-menu-item>
            </a-menu>
            <a-button>
              批量操作 <a-icon type="down" />
            </a-button>
          </a-dropdown>
        </div>
        <!-- table区域-begin -->
        <div>
          <a-table
            ref="table"
            size="middle"
            bordered
            rowKey="id"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :scroll="{ x: 1600}"
            :loading="loading"
            :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
            @change="handleTableChange">
            <span slot="action" slot-scope="text, record">
              <a @click="handleEdit(record)">编辑</a>
              <a-divider v-if="btnEnableList.indexOf(1)>-1" type="vertical" />
              <a-popconfirm v-if="btnEnableList.indexOf(1)>-1" title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                <a>删除</a>
              </a-popconfirm>
            </span>
            <!-- 状态渲染模板 -->
            <template slot="customRenderFlag" slot-scope="enabled">
              <a-tag v-if="enabled" color="green">启用</a-tag>
              <a-tag v-if="!enabled" color="orange">禁用</a-tag>
            </template>
          </a-table>
        </div>
        <!-- table区域-end -->
        <!-- 表单区域 -->
        <customer-modal ref="modalForm" @ok="modalFormOk"></customer-modal>
      </a-card>
    </a-col>
  </a-row>
</template>
<!-- BY cao_yu_li -->
<script>
  import CustomerModal from '../system/modules/CustomerModal'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { openDownloadDialog, sheet2blob} from "@/utils/util"
  import JDate from '@/components/jeecg/JDate'
  export default {
    name: "CustomerList",
    mixins:[JeecgListMixin],
    components: {
      CustomerModal,
      JDate
    },
    data () {
      return {
        labelCol: {
          span: 5
        },
        wrapperCol: {
          span: 18,
          offset: 1
        },
        // 查询条件
        queryParam: {
          supplier:'',
          type:'客户',
          telephone:'',
          phonenum:''
        },
        ipagination:{
          pageSizeOptions: ['10', '20', '30', '100', '200']
        },
        // 表头
        columns: [
          // {
          //   title: '#',
          //   dataIndex: '',
          //   key:'rowIndex',
          //   width:60,
          //   align:"center",
          //   customRender:function (t,r,index) {
          //     return parseInt(index)+1;
          //   },
          //   fixed: 'left'
          // },
          { title: '任务单号',dataIndex: 'code',key:'1',width:150,align:"center",fixed: 'left'},
          { title: '产品名称', dataIndex: 'productName',key:'2',width:150,align:"center",fixed: 'left'},
          { title: '下发日期', dataIndex: 'issueDate',key:'3',width:150,align:"center"},
          { title: '发货日期', dataIndex: 'deliverDate',key:'4',width:100,align:"center"},
          { title: '所属行业', dataIndex: 'industry',key:'5',width:100,align:"center"},
          { title: '新制/重涂', dataIndex: 'makingType',key:'6',width:100,align:"center"},
          { title: '规格型号',dataIndex: 'standards',key: '7', width:100,align:"center"},
          { title: '单双面', dataIndex: 'metalUpper',key:'8',width:100,align:"center"},
          { title: '基材分类', dataIndex: 'profit',width:100,key:'9',align:"center"},
          { title: '顾客提供资料', dataIndex: 'customerProvideInfo',key:'10',width:150,align:"center"},
          { title: '基材加工方式', dataIndex: 'processingMode',key:'11',width: 200, align:"center"},
          { title: '喷砂', key: '12',dataIndex: 'sandblasting',width:100,align:"center"},
          { title: '表面处理',key: '13', dataIndex: 'processingMode', width:100, align:"center"},
          { title: '水清洗', key: '14',dataIndex: 'contractAmount', width:100,align:"center"},
          { title: '涂层-烧结', key: '15',dataIndex: 'receivedAmount', width:100,align:"center"},
          { title: '外观', key: '16',dataIndex: 'outlook',width:100,align:"center"},
          { title: '尺寸', key: '17',dataIndex: 'size',width:100,align:"center"},
          { title: '试安装', key: '18',dataIndex: 'install',width:100,align:"center"},
          { title: '打标要求', key: '19',dataIndex: 'markRequired',width:100,align:"center"},
          { title: '随货资料', key: '20',dataIndex: 'goodsInfo',width:100,align:"center"},
          { title: '包装材料', key: '21',dataIndex: 'packMaterial',width:100,align:"center"},
          { title: '包装外箱', key: '22',dataIndex: 'packBox',width:100,align:"center"},
          { title: '运输方式', key: '23',dataIndex: 'shippingMethod',width:100,align:"center"},
          // { title: '客户名称',key: '1',dataIndex: 'name',width:150,align:"center",fixed: 'left'},
          // { title: '所属行业', key: '2',dataIndex: 'industry',width:150,align:"center",fixed: 'left'},
          // { title: '业务负责人', key: '3',dataIndex: 'responsePerson',width:150,align:"center",fixed: 'left'},
          // { title: '订单类型', key: '4',dataIndex: 'orderType',width:100,align:"center",fixed: 'left'},
          // { title: '合同编号', key: '5',dataIndex: 'contractNum',width:100,align:"center"},
          // { title: '内部编码', key: '6',dataIndex: 'insideCode',width:100,align:"center"},
          // { title: '签订日期', key: '7',dataIndex: 'signDate',width:180,align:"center"},
          // { title: '基材到厂时间', key: '8',dataIndex: 'arrivedDate',width:180,align:"center"},
          // { title: '产品名称', key: '9',dataIndex: 'productName',width:150,align:"center"},
          // { title: '规格',key: '10', dataIndex: 'standards',width:70,align:"center"},
          // { title: '单位',key: '11', dataIndex: 'uom',width:70,align:"center"},
          // { title: '数量', key: '12',dataIndex: 'number',width:100,align:"center"},
          // { title: '付款方式',key: '13', dataIndex: 'paymentMethod', width:100, align:"center"},
          // { title: '合同金额', key: '14',dataIndex: 'contractAmount', width:100,align:"center"},
          // { title: '已收金额', key: '15',dataIndex: 'receivedAmount', width:100,align:"center"},
          // { title: '未收金额', key: '16',dataIndex: 'notReceivedAmount',width:100,align:"center"},
          // { title: '质保金比例', key: '17',dataIndex: 'notReceivedAmount',width:100,align:"center"},
          // { title: '回款比例', key: '18',dataIndex: 'notReceivedAmount',width:100,align:"center"},
          // { title: '新制/重涂', key: '19',dataIndex: 'type',width:100,align:"center"},
          // { title: '当日贵金属价格',key: '20', dataIndex: 'metalPrice',width:150,align:"center"},
          // { title: '贵金属上量',key: '21', dataIndex: 'metalUpper',width:120,align:"center"},
          // { title: '毛利', key: '22',dataIndex: 'profit',width:120,align:"center"},
          // { title: '同行价格',key: '23', dataIndex: 'competitorPrice',width:120,align:"center"},
          // { title: '后续情况', key: '24',dataIndex: 'afterSituation',width:200,align:"center"},


          // {
          //   title: '操作',
          //   dataIndex: 'action',
          //   key:'25',
          //   width: 100,
          //   align:"center",
          //   scopedSlots: { customRender: 'action' },
          // }
        ],
        url: {
          list: "/supplier/list",
          delete: "/supplier/delete",
          deleteBatch: "/supplier/deleteBatch",
          importExcelUrl: "/supplier/importCustomer",
          exportXlsUrl: "/supplier/exportExcel",
          batchSetStatusUrl: "/supplier/batchSetStatus"
        }
      }
    },
    computed: {
      importExcelUrl: function () {
        return `${window._CONFIG['domianURL']}${this.url.importExcelUrl}`;
      }
    },
    methods: {
      searchReset() {
        this.queryParam = {
          type:'客户',
        }
        this.loadData(1);
      },
      handleEdit: function (record) {
        this.$refs.modalForm.edit(record);
        this.$refs.modalForm.title = "编辑";
        this.$refs.modalForm.disableSubmit = false;
        if(this.btnEnableList.indexOf(1)===-1) {
          this.$refs.modalForm.isReadOnly = true
        }
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>